package com.ruoyi.job.service.impl;

import java.util.List;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datasource.annotation.Slave;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.job.mapper.EtlScriptInfoMapper;
import com.ruoyi.job.domain.EtlScriptInfo;
import com.ruoyi.job.service.IEtlScriptInfoService;

/**
 * Kettle脚本Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-31
 */
@Service
public class EtlScriptInfoServiceImpl implements IEtlScriptInfoService
{
    @Autowired
    private EtlScriptInfoMapper etlScriptInfoMapper;

    /**
     * 查询Kettle脚本
     * 
     * @param scriptId Kettle脚本ID
     * @return Kettle脚本
     */
    @Override
    public EtlScriptInfo selectEtlScriptInfoById(String scriptId)
    {
        return etlScriptInfoMapper.selectEtlScriptInfoById(scriptId);
    }

    /**
     * 查询Kettle脚本列表
     * 
     * @param etlScriptInfo Kettle脚本
     * @return Kettle脚本
     */
    @Override
    public List<EtlScriptInfo> selectEtlScriptInfoList(EtlScriptInfo etlScriptInfo)
    {
        return etlScriptInfoMapper.selectEtlScriptInfoList(etlScriptInfo);
    }

    /**
     * 新增Kettle脚本
     * 
     * @param etlScriptInfo Kettle脚本
     * @return 结果
     */
    @Override
    public int insertEtlScriptInfo(EtlScriptInfo etlScriptInfo)
    {
        etlScriptInfo.setCreateTime(DateUtils.getNowDate());
        etlScriptInfo.setDeployTime(DateUtils.getNowDate());
        etlScriptInfo.setScriptType("1");
        etlScriptInfo.setScriptFileName(etlScriptInfo.getScriptName() + ".ktr");
        etlScriptInfo.setDelFlag("0");
        return etlScriptInfoMapper.insertEtlScriptInfo(etlScriptInfo);
    }

    /**
     * 修改Kettle脚本
     * 
     * @param etlScriptInfo Kettle脚本
     * @return 结果
     */
    @Override
    public int updateEtlScriptInfo(EtlScriptInfo etlScriptInfo)
    {
        return etlScriptInfoMapper.updateEtlScriptInfo(etlScriptInfo);
    }

    /**
     * 批量删除Kettle脚本
     * 
     * @param scriptIds 需要删除的Kettle脚本ID
     * @return 结果
     */
    @Override
    public int deleteEtlScriptInfoByIds(String[] scriptIds)
    {
        return etlScriptInfoMapper.deleteEtlScriptInfoByIds(scriptIds);
    }

    /**
     * 删除Kettle脚本信息
     * 
     * @param scriptId Kettle脚本ID
     * @return 结果
     */
    @Override
    public int deleteEtlScriptInfoById(String scriptId)
    {
        return etlScriptInfoMapper.deleteEtlScriptInfoById(scriptId);
    }

    @Override
    public List<EtlScriptInfo> getTaskSchedBySeq(EtlScriptInfo etlScriptInfo) {
        return etlScriptInfoMapper.getTaskSchedBySeq(etlScriptInfo);
    }
}
